import {request} from "../request";

export function getCommentByPage(query) {
  let {ip, keyword, currentPage, pageSize, commentStatus} = query;
  return request({
    url: '/comment/getCommentByPage',
    params: {
      ip, keyword, currentPage, pageSize, commentStatus
    }
  })
}

/**
 * header中用来获取未审核评论信息的方法
 */
export function getCommentForUnchecked() {
  return request({
    url: '/comment/getCommentForUnchecked',
  })
}

/**
 * 审核评论的方法
 * @param formData 审核后的操作结果
 * @returns {返回Promise实例}
 */
export function checkComment(formData) {
  let {commentId, checkResult, commentContent, failureInfo, needSendMail} = formData;
  return request({
    url: '/comment/checkComment',
    params: {
      commentId, checkResult, commentContent, failureInfo, needSendMail
    }
  })
}

/**
 * 根据id查询评论信息
 * @param id 评论id
 */
export function getCommentById(id) {
  return request({
    url: '/comment/getCommentById',
    params: {
      id
    }
  })
}

/**
 * 修改审核信息
 * @param formData 修改审核的信息载体
 * @returns {返回Promise实例}
 */
export function modifyCheck(formData) {
  let {commentId, checkResult, commentContent, failureInfo, needSendMail} = formData;
  return request({
    url: '/comment/modifyCheck',
    params: {
      commentId, checkResult, commentContent, failureInfo, needSendMail
    }
  })
}

/**
 * 批量审核评论
 * @param ids 评论的id的集合
 */
export function batchCheckComment(formData) {
  let {commentId, checkResult, commentContent, failureInfo, needSendMail} = formData;
  return request({
    url: '/comment/batchCheckComment',
    params: {
      commentId, checkResult, commentContent, failureInfo, needSendMail
    }
  })
}

/**
 * 根据ids删除评论
 * @param id 评论id的集合
 */
export function deleteByIds(ids) {
  return request({
    url: '/comment/deleteByIds',
    params: {
      ids
    }
  })
}

